package com.yida.gwj.scene.expend.controller;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yida.common.core.utils.poi.ExcelUtil;
import com.yida.common.core.web.controller.BaseController;
import com.yida.common.core.web.domain.AjaxResult;
import com.yida.common.core.web.page.TableDataInfo;
import com.yida.common.log.annotation.Log;
import com.yida.common.log.enums.BusinessType;
import com.yida.common.security.annotation.RequiresPermissions;
import com.yida.gwj.scene.expend.domain.GwjSceneExpendBusinessCommunity;
import com.yida.gwj.scene.expend.service.IGwjSceneExpendBusinessCommunityService;

/**
 * 业务小区信息（线下支出）Controller
 * 
 * @author hmh
 * @date 2023-08-14
 */
@RestController
@RequestMapping("/community")
public class GwjSceneExpendBusinessCommunityController extends BaseController {
    @Autowired
    private IGwjSceneExpendBusinessCommunityService gwjSceneExpendBusinessCommunityService;

    /**
     * 查询业务小区信息（线下支出）列表
     */
    @RequiresPermissions("gwj:scene:expend:community:list")
    @GetMapping("/list")
    public TableDataInfo list(GwjSceneExpendBusinessCommunity gwjSceneExpendBusinessCommunity) {
        startPage();
        List<GwjSceneExpendBusinessCommunity> list = gwjSceneExpendBusinessCommunityService.selectGwjSceneExpendBusinessCommunityList(gwjSceneExpendBusinessCommunity);
        return getDataTable(list);
    }

    /**
     * 导出业务小区信息（线下支出）列表
     */
    @RequiresPermissions("gwj:scene:expend:community:export")
    @Log(title = "业务小区信息（线下支出）", businessType = BusinessType.EXPORT, systemName = "gwj")
    @PostMapping("/export")
    public void export(HttpServletResponse response, GwjSceneExpendBusinessCommunity gwjSceneExpendBusinessCommunity) {
        List<GwjSceneExpendBusinessCommunity> list = gwjSceneExpendBusinessCommunityService.selectGwjSceneExpendBusinessCommunityList(gwjSceneExpendBusinessCommunity);
        ExcelUtil<GwjSceneExpendBusinessCommunity> util = new ExcelUtil<GwjSceneExpendBusinessCommunity>(GwjSceneExpendBusinessCommunity.class);
        util.exportExcel(response, list, "业务小区信息（线下支出）数据");
    }

    /**
     * 获取业务小区信息（线下支出）详细信息
     */
    @RequiresPermissions("gwj:scene:expend:community:query")
    @GetMapping(value = "/{bizCommunityId}")
    public AjaxResult getInfo(@PathVariable("bizCommunityId") Long bizCommunityId) {
        return AjaxResult.success(gwjSceneExpendBusinessCommunityService.selectGwjSceneExpendBusinessCommunityByBizCommunityId(bizCommunityId));
    }

    /**
     * 新增业务小区信息（线下支出）
     */
    @RequiresPermissions("gwj:scene:expend:community:add")
    @Log(title = "业务小区信息（线下支出）", businessType = BusinessType.INSERT, systemName = "gwj")
    @PostMapping
    public AjaxResult add(@RequestBody GwjSceneExpendBusinessCommunity gwjSceneExpendBusinessCommunity) {
        return toAjax(gwjSceneExpendBusinessCommunityService.insertGwjSceneExpendBusinessCommunity(gwjSceneExpendBusinessCommunity));
    }

    /**
     * 修改业务小区信息（线下支出）
     */
    @RequiresPermissions("gwj:scene:expend:community:edit")
    @Log(title = "业务小区信息（线下支出）", businessType = BusinessType.UPDATE, systemName = "gwj")
    @PutMapping
    public AjaxResult edit(@RequestBody GwjSceneExpendBusinessCommunity gwjSceneExpendBusinessCommunity) {
        return toAjax(gwjSceneExpendBusinessCommunityService.updateGwjSceneExpendBusinessCommunity(gwjSceneExpendBusinessCommunity));
    }

    /**
     * 删除业务小区信息（线下支出）
     */
    @RequiresPermissions("gwj:scene:expend:community:remove")
    @Log(title = "业务小区信息（线下支出）", businessType = BusinessType.DELETE, systemName = "gwj")
    @DeleteMapping("/{bizCommunityIds}")
    public AjaxResult remove(@PathVariable Long[] bizCommunityIds) {
        return toAjax(gwjSceneExpendBusinessCommunityService.deleteGwjSceneExpendBusinessCommunityByBizCommunityIds(bizCommunityIds));
    }
}
